﻿//by  张海军 710605420@qq.com
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace LazyFramework
{
    public static class LazyFrameworkUtils
    {
       static public void SetLayer(GameObject go,LayerMask layer)
        {
            UnityEngine.Assertions.Assert.IsFalse(go == null);
            if (layer == -1)
            {
                Debug.Log("Layer中不存在,请手动添加LayerName");
                return;
            }
            go.layer = layer;
            foreach (Transform child in go.transform)
            {
                SetLayer(child, layer);
            }
        }
        static public void SetLayer(GameObject go, string layer)
        {
            UnityEngine.Assertions.Assert.IsFalse(go == null);
            if (LayerMask.NameToLayer(layer) == -1)
            {
                Debug.Log("Layer中不存在,请手动添加LayerName");
                return;
            }
            go.layer = LayerMask.NameToLayer(layer);
            foreach (Transform child in go.transform)
            {
                SetLayer(child, layer);
            }
        }
        static public void SetLayer(Transform trans, LayerMask layer)
        {
            UnityEngine.Assertions.Assert.IsFalse(trans == null);
            if (layer == -1)
            {
                Debug.Log("Layer中不存在,请手动添加LayerName");
                return;
            }
            trans.gameObject.layer = layer;
            foreach (Transform child in trans)
            {
                SetLayer(child, layer);
            }
        }
        static public void SetLayer(Transform trans, string layer)
        {
            UnityEngine.Assertions.Assert.IsFalse(trans == null);
            if (LayerMask.NameToLayer(layer) == -1)
            {
                Debug.Log("Layer中不存在,请手动添加LayerName");
                return;
            }
            trans.gameObject.layer = LayerMask.NameToLayer(layer);
            foreach (Transform child in trans)
            {
                SetLayer(child, layer);
            }
        }
        
}

}
